#!/usr/bin/python

import hashlib, string, sys

in_md5_block = False
current_block = ""
current_block_name = ""
md5_begin_tag = "// md5begin"
md5_end_tag = "// md5end"
comment_begin = "//"

for line in sys.stdin:
  if line.startswith(md5_begin_tag):
    in_md5_block = True
    current_block_name = line[len(md5_begin_tag) + 1 : -1]
  elif line.startswith(md5_end_tag):
    in_md5_block = False
    hash = hashlib.md5(current_block).hexdigest()
    print current_block_name + " " + hash
    current_block = ""
  elif line.lstrip().startswith(comment_begin):
    continue
  elif in_md5_block:
    current_block += line.translate(None, string.whitespace)
